import ruleOpt from '@/biz/option/rule.js'
import dt from '@dt/dt'
import houseOpt from '@/biz/option/house.js'

let _this = null
let allotList = [{ key: '1', value: '生成分配任务' }, { key: '0', value: '不生成' }]
let followList = [{ key: '1', value: '生成跟进任务' }, { key: '0', value: '不生成' }]

function isCreateTask(type) {
  let obj = {
    title: '是否生成任务',
    key: 'isCreateTask',
    radio: {
      options: type == 1 ? allotList : followList,
    },
    rules: [{
      required: true,
      message: '请选择是否生成任务',
      trigger: 'blur,change'
    }]
  }
  return obj
}

function allotMode() {
  let arr = [
  {
    title: '分配方式',
    key: 'type',
    radio: {
      options: [{ key: '1', value: '仅分配至案场' }, { key: '2', value: '分配至指定顾问' }],
    },
    change: (data) => {
      _this.info.isCreateTask = ''
      arr.splice(1, arr.length)
      arr.push(isCreateTask(data.value))
      _this.changeHandel(data)
    },
    rules: [{
      required: true,
      message: '请选择分配方式',
      trigger: 'blur,change'
    }]
  }]
  return arr
}
class ExamineOpt {
  constructor(vm) {
    this.opts = {}
    _this = vm
    this.build()
  }
  houseInfo(info) {
    let opt = {
      isShowCity: true
    }
    return houseOpt.create(opt)
  }
  build() {
    this.opts = {
      options1: [
        this.houseInfo(_this.info),
        {
          title: '隐私号回拨',
          key: 'isPrivacy',
          radio: {
            options: [{ key: '1', value: '是' }, { key: '0', value: '否' }],
          },
          change: (val) => {
            _this.changeHandel(val)
          },
          rules: [{
            required: true,
            message: '请选择隐私号回拨',
            trigger: 'blur,change'
          }]
        },
      ],
      options2: allotMode(),
    }
  }
  options() {
    return this.opts
  }
}

export default ExamineOpt